package com.itehima.stream;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class Demo01 {
    public static void main(String[] args) {
        //实现单列集合的stream流
        ArrayList<String> list = new ArrayList<>();

        //list作为collection的实现类，可以直接调用collection的方法
        Collections.addAll(list,"a","b","c","d","e");
        //将集合中的数据放到流水线上
        Stream<String> stream1 = list.stream();
        //打印流水线上的数据
//        stream1.forEach(new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//                System.out.print(" "+s);
//            }
//        });
        stream1.forEach(s->System.out.print(" "+s));

        //我们也可以一步到位
        list.stream().forEach(s-> System.out.println(s));
    }
}
